package game.module.account;

import game.entity.Hero;
import game.serverenv.GameServerOnlineManager;
import lion.ann.MsgCodeAnn;
import lion.codec.INotNeedAuthProcessor;
import lion.core.GamePlayer;
import lion.message.MyRequestMsg;
import lion.processor.IThreadProcessor;
import lion.processor.MsgProcessor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@MsgCodeAnn(msgcode = 10001, accessLimit = 1000)
public class LoginGameProcessor10001 extends MsgProcessor implements IThreadProcessor, INotNeedAuthProcessor {

	public static final Logger logger = LoggerFactory.getLogger(LoginGameProcessor10001.class);

	@Autowired
	private AccountManager accountManager;
	
	@Autowired
	private GameServerOnlineManager gameServerOnlineManager;

	@Override
	public void process(GamePlayer session, MyRequestMsg request) throws Exception {
		int gameaccount = request.getInt();
		int characterid = request.getInt();
		String param = request.getString();
		logger.info("request enter game ,account id={},hero id={},param={}", new Object[] { gameaccount, characterid, param });
		Hero hero = new Hero();
		hero.setId(characterid);
		hero.setAccountId(gameaccount);
		hero.setName("herbert");
		hero.setPlayer(session);
		session.setCurrentCharacter(hero);
		session.setValidate(true);
		gameServerOnlineManager.addCharacter(hero);
		session.sendMsg(new LoginGameResp());
		accountManager.testDb();
	}

}
